home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 September / Chip_2000-09_cd1.bin / sharewar / Slunec / app / 16 / MISC.SWG / 0016_DataFlex 2.3b Datafile.pas < prev    next >
Pascal/Delphi Source File  |  1997-05-11  |  7KB  |  164 lines

  1. DATAFLEX 2.3B DATAFILE HEADER STRUCTURE
  2.  
  3. By Peter M. Grillo
  4. MAINSTREAM COMPUTER CONSULTING
  5.  
  6.  
  7. Following  is  the  structure of the  DataFlex  .DAT  file for 2.3. Data
  8. Access  Corporation  has  deemed  the  structure  of  the  .DAT  file as
  9. proprietary.  The  following definition of a  2.3  .DAT file was derived
  10. independently  by  myself and any problem  arising  from the use of this
  11. information will be your problem. Please do not call DAC and snivel. Use
  12. at own risk. Please do not upload this to DAC's BBS.
  13.  
  14. DAC  has indicated to me that I can release this information providing I
  15. include the prior disclaimer.
  16.  
  17. All  that  aside, this is everything I  know about a DataFlex .DAT file.
  18. The overall layout of a 2.3 .DAT file is header, null record and data.
  19.  
  20. The  header  contains information about  the file definition. Just about
  21. everything  you  define in DFFILE can be  found in the header except for
  22. tag  names. It is possible to read the header of a 2.3 .DAT file and the
  23. corresponding .TAG file to produce a perfect .DEF file.
  24.  
  25. The following show offsets into the header:
  26. (LSB = Least significant byte)
  27. (MSBT = Most significant bit)
  28.  
  29. DECIMAL         HEX      DESCRIPTION
  30.  
  31. 01 - 04         00 - 03  HIGHEST RECORD COUNT EVER (LSB FIRST)
  32.  
  33. 09 - 12         08 - 0B  RECORD COUNT (LSB FIRST)
  34. 13 - 16         0C - 0F  MAXIMUM NUMBER OF RECORDS (LSB FIRST)
  35.  
  36. 79 - 80         4E - 4F  RECORD LENGTH (LSB FIRST)
  37.  
  38. 89              58       DELETED SPACE (1=REUSED, 0=NOT REUSED)
  39. 90              59       NUMBER OF FIELDS
  40.  
  41. 93              5C       MULTIUSER REREAD (1=ACTIVE, 0=INACTIVE)
  42.  
  43. 101             64       NUMBER OF FIELDS IN INDEX 1 (MSBT SET 1 IF BATCH)
  44. 102-108         65 - 6B  FIELD SEGMENTS OF INDEX 1
  45. 109             6C       NUMBER OF FIELDS IN INDEX 2 (MSBT SET 1 IF BATCH)
  46. 110-116         6D - 73  FIELD SEGMENTS OF INDEX 2
  47. 117             74       NUMBER OF FIELDS IN INDEX 3 (MSBT SET 1 IF BATCH)
  48. 118-124         75 - 7B  FIELD SEGMENTS OF INDEX 3
  49. 125             7C       NUMBER OF FIELDS IN INDEX 4 (MSBT SET 1 IF BATCH)
  50. 126-132         7D - 83  FIELD SEGMENTS OF INDEX 4
  51. 133             84       NUMBER OF FIELDS IN INDEX 5 (MSBT SET 1 IF BATCH)
  52. 134-140         85 - 8B  FIELD SEGMENTS OF INDEX 5
  53. 141             8C       NUMBER OF FIELDS IN INDEX 6 (MSBT SET 1 IF BATCH)
  54. 142-148         8D - 93  FIELD SEGMENTS OF INDEX 6
  55. 149             94       NUMBER OF FIELDS IN INDEX 7 (MSBT SET 1 IF BATCH)
  56. 150-156         95 - 9B  FIELD SEGMENTS OF INDEX 7
  57. 157             9C       NUMBER OF FIELDS IN INDEX 8 (MSBT SET 1 IF BATCH)
  58. 158-162         9D - A3  FIELD SEGMENTS OF INDEX 8
  59. 163             A4       NUMBER OF FIELDS IN INDEX 9 (MSBT SET 1 IF BATCH)
  60. 164-170         A5 - AB  FIELD SEGMENTS OF INDEX 9
  61. 171             AC       NUMBER OF FIELDS IN INDEX 10 (MSBT SET 1 IF BATCH)
  62. 172-108         AD - B3  FIELD SEGMENTS OF INDEX 10
  63.  
  64. 181 -183        B4 - BC  FILE ROOT NAME (NULL TERMINATED)
  65.  
  66.  
  67. START OF FIELD DEFINITIONS.
  68. REPEAT FOR EACH FIELD.
  69.  
  70. 197-198         C4 - C5  FIELD OFFSET (LSB FIRST)
  71. 199             C6       MSBT=MAIN INDEX, LSBT=(DECIMAL POINTS/2)
  72. 200             C7       FIELD LENGTH
  73. 201             C8       FIELD TYPE 00=ASCII, 01=NUMERIC, 02=DATE, 03=OVERLAP
  74. 202             C9       RELATES TO FILE NUMBER
  75. 203-204         CA - CB  RELATES TO FIELD NUMBER (LSB FIRST)
  76. ...-...         .. - ..  (REPEAT FOR EACH FIELD)
  77.  
  78.  
  79. The  null  record  follows the header  and  usually  contains 00h's. The
  80. number  of bytes in the null record  corresponds to the record length of
  81. the file. The null record is record number zero.
  82.  
  83. The  data that follows are records in order of record number. The number
  84. of  bytes  in each record corresponds  to the record length. Records are
  85. grouped  together  by  blocks  of 512  bytes.  Not  every record length,
  86. however, divides evenly into 512 so you get the occurrence of fill bytes
  87. or  0FFh's  to round out a group  of  records to 512 bytes. Consider the
  88. following:
  89.  
  90. Record Length                   Layout
  91. 128                             Divides into 512 evenly so no fill
  92.                                 bytes are used
  93.  
  94. 170                             Divided by 512 is 3 with a remainder
  95.                                 of 2 so after every 3 records
  96.                                 (starting at record 0) the are 2 fill
  97.                                 bytes (0FFh's)
  98.  
  99. Here is a table of common record lengths:
  100.  
  101. Record Length   Records in 512 Group    Number of Fill Bytes
  102.  
  103. 256                     2                       0
  104. 170                     3                       2
  105. 128                     4                       0
  106. 102                     5                       2
  107. 85                      6                       2
  108. 73                      7                       1
  109. 64                      8                       0
  110. 56                      9                       8
  111. 51                      10                      2
  112. 46                      11                      6
  113. 42                      12                      8
  114. 39                      13                      5
  115. 36                      14                      8
  116. 34                      15                      2
  117. 32                      16                      0
  118. 30                      17                      2
  119. 28                      18                      8
  120. 26                      19                      18
  121. 25                      20                      12
  122. 24                      21                      8
  123. 23                      22                      6
  124. 22                      23                      6
  125. 21                      24                      8
  126. 20                      25                      12
  127. 19                      26                      18
  128. 18                      28                      8
  129. 17                      30                      2
  130. 16                      32                      0
  131. 15                      34                      2
  132. 14                      36                      8
  133. 13                      39                      5
  134. 12                      42                      8
  135. 11                      46                      6
  136. 10                      51                      2
  137. 9                       56                      8
  138. 8                       64                      0
  139.  
  140. > [fold]  [
  141. > [fold]  [
  142. Deleted records are filled with 00h's until reused.
  143.  
  144. DataFlex  .DAT  files can be opened  from .FLX files using DIRECT_INPUT.
  145. You can then use READ_BLOCK commands to read information.
  146.  
  147. Reading  the  FILELIST.CFG  file  is  also  much  more  efficient  using
  148. DIRECT_INPUT  and  READ_BLOCK.  The first 128  bytes  are  fill and each
  149. successive  block of 128 bytes is a file in the list. In other words, if
  150. you  want  file 15 then  DIRECT_INPUT  'FILELIST.CFG' and READ_BLOCK off
  151. (15*128)  bytes.  This  would point you to  the  block for file 15. From
  152. there  you  can read off bytes to  find  the Root Name, Description, and
  153. DataFlex Name using the following layout.
  154.  
  155. > [fold]  ]
  156. > [fold]  ]
  157. DECIMAL         HEX      DESCRIPTION
  158.  
  159. 01 - 41         00 - 28  FILE ROOT NAME (NULL TERMINATED)
  160. 42 - 74         29 - 49  FILE DESCRIPTION (NULL TERMINATED)
  161. 75 - 128        4A - 7F  DATAFLEX FILE NAME (NULL TERMINATED)
  162.  
  163. > [fold]  2
  164.